﻿using Ledict.Core.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ledict.ConditionExtract.DAL
{
  public  class SYS_ArgumentDAL
    {
        private string DbName;
        private string DbNameDoc;
        public SYS_ArgumentDAL()
        {
            DbName = "LdtCommonManage";
            DbNameDoc = "JudgeDoc";
        }

        /// <summary>
        /// 获取字典值数据
        /// </summary>
        public DataTable GetSYS_ArgumentDataByATID(string atId)
        {
            string strSql = string.Format(@" select AM_ShowIndex,AM_Code,AM_Name,AM_SameWords,AM_Remark from SYS_Argument where AT_ID ='{0}'  ", atId);
            Database oBase = DatabaseFactory.CreateDatabase(DbNameDoc);
            DbCommand oCmd = oBase.GetSqlStringCommand(strSql.ToString());
            DataTable dt = oBase.ExecuteDataSet(oCmd).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                return dt;
            }
            return new DataTable();
        }

        /// <summary>
        /// 获取字典数据
        /// </summary>
        public DataTable GetSYS_ArgumentTypeData()
        {
            string strSql = string.Format(@" select AT_ID, AT_Name, AT_Code, AT_WordsMode,AT_RelatCaseType from dbo.SYS_ArgumentType ");
            Database oBase = DatabaseFactory.CreateDatabase(DbNameDoc);
            DbCommand oCmd = oBase.GetSqlStringCommand(strSql.ToString());
            DataTable dt = oBase.ExecuteDataSet(oCmd).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                return dt;
            }
            return new DataTable();
        }
    }
}
